import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import set_node_cls from '@dfeidao/atom-web/ui/set-node-cls';
import show from '@dfeidao/atom-web/ui/show';
import fire from '@dfeidao/atom-web/msg/fire';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import p001 from './p001';
import p002 from './p002';
import format from '@dfeidao/atom-web/dt/format';

export default async function a001(fd: IFeidaoAiBrowserComponent,ss:string) {
	// todo
	//数据读取start
	const res =await nodejs<{d1:{}}>("order-satisfaction/zj-000004/s001",{filter:{work_bill_no:ss}});
	const res1 =await nodejs<{d1:{}}>("order-satisfaction/zj-000004/s002",{filter:{work_bill_no:ss}});
	//数据读取End
		if(res.d1[0].source_type=="1"){
			res.d1[0].source_type="总服务台";
		}else if(res.d1[0].source_type=="2"){
			res.d1[0].source_type="服务台";
	
		}else if(res.d1[0].source_type=="3"){
			res.d1[0].source_type="客户报障";
	
		}else{
			res.d1[0].source_type="内部报障";
		}
		if(res.d1[0].work_order_status=="1"){
			res.d1[0].work_order_status="结单";
		}else if(res.d1[0].work_order_status=="2"){
			res.d1[0].work_order_status="完成";
	
		}else if(res.d1[0].work_order_status=="3"){
			res.d1[0].work_order_status="挂起";
	
		}else if(res.d1[0].work_order_status=="4"){
			res.d1[0].work_order_status="未派单";
		}else{
			res.d1[0].work_order_status="进行中";
		}
		if(res1.d1[0].cust_sat=="1"){
			res1.d1[0].cust_sat="非常满意";
		}else if(res1.d1[0].cust_sat=="2"){
			res1.d1[0].cust_sat="满意";
	
		}else if(res1.d1[0].cust_sat=="3"){
			res1.d1[0].cust_sat="一般";
	
		}else if(res1.d1[0].cust_sat=="4"){
			res1.d1[0].cust_sat="不满意";
		}else{
			res1.d1[0].cust_sat="未回访";
		}

		res.d1[0].create_time= format(res.d1[0].create_time, 2);
		res.d1[0].finish_time= format(res.d1[0].finish_time, 2);
		res.d1[0].start_time= format(res.d1[0].start_time, 2);
	
		
	//数据渲染Start
	render(fd,res.d1,p001,'p001','inner');
	render(fd,res1.d1,p002,'p002','inner');
	//数据渲染Start
	//显示模板start
	const see = fd.data.node.querySelector<HTMLDivElement>("[data-id='see']");
	set_node_cls(see,'display-n',false);
	show(fd.data.node);
	fire('zj-000001','a002');
	fire('zj-000002','a004');
	//显示模板end


}
